var t = require("../../../utils/util.js"), e = getApp();

e.globalData.url;

Page({
    data: {
        currentSize: 0,
        phone: "无",
        start: "无状态",
        stop: "无状态",
        restart: "无状态"
    },
    onLoad: function(t) {
        var e = this;
        e.getUserInfo(), wx.getStorageInfo({
            success: function(t) {
                e.setData({
                    currentSize: t.currentSize
                });
            }
        });
    },
    onShow: function() {
        var t = this;
        wx.getStorageInfo({
            success: function(e) {
                t.setData({
                    currentSize: e.currentSize
                });
            }
        });
    },
    getUserInfo: function() {
        var n = this, o = e.globalData.token;
        t.request(e, "wx/cust/getUserInfo", "POST", {
            token: o
        }, function(t) {
            n.setData({
                phone: t.data.phone,
                card: null == t.data.idCard ? "无" : t.data.idCard
            });
        }, function(t) {});
    },
    clear: function() {
        var t = this;
        wx.clearStorageSync(), wx.getStorageInfo({
            success: function(e) {
                wx.showToast({
                    title: "清除成功",
                    icon: "none"
                }), t.setData({
                    currentSize: 0
                });
            }
        });
    },
    getPhoneNumber: function(n) {
        wx.setStorageSync("ivPhone", n.detail.iv), wx.setStorageSync("encryptedDataPhone", n.detail.encryptedData), 
        t.registerPhone(n.detail.encryptedData, n.detail.iv, e), wx.showToast({
            title: "请刷新界面",
            icon: "none"
        });
    },
    check: function() {
        var t = wx.getUpdateManager();
        t.onCheckForUpdate(function(t) {
            t.hasUpdate || wx.showToast({
                title: "当前是最新版本",
                icon: "none"
            });
        }), t.onUpdateReady(function() {
            wx.showModal({
                title: "更新提示",
                content: "新版本已经准备好，是否重启应用？",
                success: function(e) {
                    e.confirm && t.applyUpdate();
                }
            });
        }), t.onUpdateFailed(function() {
            wx.showToast({
                title: "更新失败",
                icon: "none"
            });
        });
    },
    onPullDownRefresh: function() {
        this.getUserInfo(), wx.showNavigationBarLoading(), setTimeout(function() {
            wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
        }, 1500);
    }
});